<?php
/**
 *   File functions:
 *   Send player to jail
 *
 *   @name                 : jail.php                            
 *   @copyright            : (C) 2006 Vallheru Team based on Gamers-Fusion ver 2.5
 *   @author               : thindil <thindil@users.sourceforge.net>
 *   @author               : eyescream <tduda@users.sourceforge.net>
 *   @version              : 1.3
 *   @since                : 27.11.2006
 *
 */

//
//
//       This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// $Id: jail.php 856 2006-11-29 17:30:36Z thindil $

/**
* Ban and unban players by IP, emali, nick or ID
*/
if (isset($_GET['view']) && $_GET['view'] == 'ban') 
{
    $smarty -> assign(array("Banlist" => BAN_LIST,
        "Baninfo" => BAN_INFO,
        "Banvalue" => BAN_VALUE,
        "Banip" => BAN_IP,
        "Banemail" => BAN_EMAIL,
        "Bannick" => BAN_NICK,
        "Banid" => BAN_ID,
        "Abanpl" => A_BAN_PL,
        "Aunban" => A_UNBAN,
        "Anext" => A_NEXT,
        "Bantype" => BAN_TYPE,
        "Banval" => BAN_VAL,
        "Banned" => BANNED));
    /**
    * Banlist
    */
    $arrtype = array();
    $arramount = array();
    $i = 0;
    $ban = $db -> Execute("SELECT type, amount FROM ban");
    while (!$ban -> EOF)
    {
        $arrtype[$i] = $ban -> fields['type'];
        $arramount[$i] = $ban -> fields['amount'];
        $i = $i + 1;
        $ban -> MoveNext();
    }
    $ban -> Close();
    $smarty -> assign(array("Type" => $arrtype, 
        "Amount" => $arramount));
    if (isset($_GET['step']) && $_GET['step'] == 'modify') 
    {
        $strAmount = $db -> qstr($_POST['amount'], get_magic_quotes_gpc());
        /**
        * Ban player
        */
        if ($_POST['action'] == 'ban') 
        {
            $db -> Execute("INSERT INTO ban (type, amount) VALUES('".$_POST['type']."', ".$strAmount.")");
            $smarty -> assign("Message", YOU_BAN." <b>".$_POST['type']."</b> ".$_POST['amount'].". (<a href=\"admin.php?view=ban\">".REFRESH."</a>)");
        }
        /**
        * Unban player
        */
        if ($_POST['action'] == 'unban') 
        {
            $db -> Execute("DELETE FROM ban WHERE type='".$_POST['type']."' AND amount=".$strAmount);
            $smarty -> assign("Message", YOU_UNBAN." <b>".$_POST['type']."</b> ".$_POST['amount'].". (<a href=\"admin.php?view=ban\">".REFRESH."</a>)");
        }
    }
}
?>
